package com.example.demo.controller;

import com.alibaba.fastjson.JSONObject;
import com.example.demo.Dao.PageDto;
import com.example.demo.zhoushengwen.Entity.Person;
import com.example.demo.zhoushengwen.Entity.User;
import com.example.demo.zhoushengwen.frame.error.NeedRight;
import com.example.demo.zhoushengwen.frame.protocol.R;
import com.example.demo.zhoushengwen.frame.protocol.Response;
import com.example.demo.zhoushengwen.frame.utils.JSONObjectUtil;
import com.github.pagehelper.PageHelper;
import org.apache.commons.lang3.StringUtils;
import org.omg.CORBA.UnknownUserException;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.text.ParseException;
import java.util.ArrayList;
import java.util.List;

@Controller
public class ErrorConroller {
    @ResponseBody
    @RequestMapping("/errorKind")
    @NeedRight
    public Response<R> errorKind(){
        User user=new User();
        user.setName("周生文");
        user.setAge(26);

        return new Response<R>(new R());
    }


    @ResponseBody
    @RequestMapping("/PageDtoLimit")
    @NeedRight
    public JSONObject PageDtoLimit(@RequestBody Person person) throws ParseException {

      //  PageHelper.startPage(person.getPage(), person.getLimit());
        ArrayList<Person> userArrayList = new ArrayList<Person>();
        for (int i = 0; i < 20; i++) {
            userArrayList.add(new Person(i+"",i+10+"","chenYao"));
        }
        PageDto<Person> pageInfo = new PageDto<Person>(userArrayList);
        return JSONObjectUtil.toLayuiTableDatas(pageInfo);
    }
}
